<html>
	{% include "../common_head.html" %}
	<body>
	{% include "../common_menus.html" %}
	<div id="content">
	{% if current_member.isLiaisonOrManagerOrOwner %}
		<div id="rakontu_form_style" class="rakontu_form">
		<form action="/{{dir_liaise}}/{{url_batch}}?{{rakontu.urlQuery}}" method="post" enctype="multipart/form-data">
		
		<h2>{{template_batch_story_entry}} {{"batch_story_entry"|caution}}</h2>

	    <p>{{template_choose_csv_file_for_batch}}:
	    <input type="file" name="import" size="40" accept="csv"/> 
	    {{"entry_CSV_import"|info}}
	    <input type="submit" name="importEntriesFromCSV" value="{{button_add_stories}}" class="button"></p>
	    <p>{{template_or_enter_stories}}</p>

		{% for i in num_entries|makeRange %}
			<h3>{{template_story}} {{i|add:1}}</h3>
			<fieldset>
			<table cellpadding=4 cellspacing=0 style="width:100%;">
			<tr><th>{{template_collected_from}} 
				{% ifequal i 0 %}
					{{"entering_batch_stories_collected_from_members"|tip}}
				{% endifequal %}
				</th><td>
				<select name="source|{{i}}">
					<option value="none">({{term_choose}})</option>
					{% if current_member.isManagerOrOwner %}
						{% for member in online_members %}
							<option value="{{member.key}}">{{member.nickname}}</option>
						{% endfor %}
						{% for member in offline_members %}
							<option value="{{member.key}}">{{member.nickname}}</option>
						{% endfor %}
					{% else %}
						{% for member in my_offline_members %}
							<option value="{{member.key}}">{{member.nickname}}</option>
						{% endfor %}
					{% endif %}
				</select>
			{% if character_allowed %}
				<tr><th>{{template_attributed_to}}</th><td>
					<select name="attribution|{{i}}">
						<option value="member"
							>{{template_selected_member}}</option>
						{% if rakontu.getActiveCharacters %}
							{% for character in rakontu.getActiveCharacters %}
								<option value="{{character.key}}"
								>{{character.name}}</option>
							{% endfor %}
						{% endif %}
					</select></p>
				</td></tr>
			{% endif %}
			<tr><th>{{template_date_collected}}<br/></th>
			<td>
	  			 {{template_year}} <input type="text" name="year|{{i}}" size="4" value="" maxlength="4"/>
	  			 {{template_month}} <input type="text" name="month|{{i}}" size="4" value="" maxlength="2"/>
	  			 {{template_day}} <input type="text" name="day|{{i}}" size="4" value="" maxlength="2"/>
	  			 {{"offline_collection_dates"|tip}}
			</td><tr>
			<tr>
				<th>{{template_title}}</th>
				<td><input type="text" name="title|{{i}}" size="60" value=""/></td><tr>
			<th>{{template_content}}</th><td>
				<table style="width:100%; border:none">
				<tr><td class="noborder">
				<textarea name="text|{{i}}" rows="5" cols="60"></textarea>
				</td><td class="noborder" width="80">
				<p>{{template_interpret_as}} {{"interpreting_texts"|tip}}</p>
					<select name="textFormat|{{i}}">
					{% for i in text_formats|makeRangeFromListLength %}
						<option value="{{text_formats|listLookup:i}}">
						{{text_formats_display|listLookup:i}}</option>
					{% endfor %}
					</select>
				</td></tr></table>
			</td></tr>
			{% if rakontu.allowsAttachments %}
				<tr><th>{{template_attachments}}</th><td>
					{% for a in rakontu.maxNumAttachments|makeRange %}
						<input type="text" name="attachmentName|{{i}}|{{a}}" size="40" maxlength="{{maxlength_name}}"/>
						<input type="file" name="attachment|{{i}}|{{a}}" size="30"/><br/>
					{% endfor %}
				</td></tr>
			{% endif %}
			{% if questions %}
				<tr><th>{{template_questions}}</th><td>
					<table style="border:none;width:100%">
					{% for question in questions %}
						<tr><td class="noborder" align="right">
							{{ question.text }}
						</td><td class="noborder">
							{% ifequal question.type "text" %}
								<input type="text" size="80"" name="{{i}}|{{question.key}}" value="" maxlength="{{maxlength_subject_or_comment}}"/>
							{% endifequal %}
							{% if question.isOrdinalOrNominal %}
								{% if question.multiple %}
									{% for choice in question.choices %}
										{% if choice|slugify %}
											<p><input type="checkbox" name="{{i}}|{{question.key}}|{{choice}}" value="yes" id="{{i}}|{{question.key}}|{{choice}}" 
											/><label for="{{i}}|{{question.key}}|{{choice}}">{{choice}}</label></p>
										{% endif %}
									{% endfor %}
								{% else %}
									<select name="{{i}}|{{question.key}}"><option value="none">({{term_choose}})</option>
									{% for choice in question.choices %}
										{% if choice|slugify %}
										<option value="{{choice}}"
											{% for answer in answers %}
												{% ifequal answer.questionKey question.key %}
													{% ifequal answer.answerIfText choice %}
														selected="selected"
													{% endifequal %}
												{% endifequal %}
											{% endfor %}
										/>{{choice}}</option>
										{% endif %}
									{% endfor %}
									</select>			
								{% endif %}
							{% endif %}
							{% ifequal question.type "boolean" %}
								<p><select name="{{i}}|{{question.key}}" id="{{i}}|{{question.key}}">
								<option value="yes">{{question.positiveResponseIfBoolean}}</option>
								<option value="no">{{question.negativeResponseIfBoolean}}</option>
								</select>
								</p>
							{% endifequal %}
							{% ifequal question.type "value" %}
								<input type="text" size="60" name="{{i}}|{{question.key}}" value="" maxlength="{{maxlength_number}}"/>
								<p><i>{{template_enter_number}} {{question.minIfValue}} {{template_and}} {{question.maxIfValue}}.</i></p>
							{% endifequal %}
						</td></tr>
					{% endfor %}
					</table>
				</td></tr>
			{% endif %}
			<tr><th>{{template_comment}}</br></th><td>
				<p>{{template_subject}} <input type="text" size="60" name="commentSubject|{{i}}" value="" maxlength="{{maxlength_subject_or_comment}}"/></p>
				<table style="width:100%; border:none">
				<tr><td class="noborder">
				<textarea name="comment|{{i}}" rows="3" cols="60"></textarea>
				</td><td class="noborder" width="80">
				<p>{{template_interpret_as}}</p>
					<select name="commentFormat|{{i}}">
					{% for i in text_formats|makeRangeFromListLength %}
						<option value="{{text_formats|listLookup:i}}">
						{{text_formats_display|listLookup:i}}</option>
					{% endfor %}
					</select>
				</td></tr></table>
			</td></tr>
			<tr><th>{{template_tags}}</br></th><td>
				{% for j in num_tags_in_tag_set|makeRange %}
					<input type="text" size="12" name="tag|{{i}}|{{j}}" value="" maxlength="{{maxlength_tag_or_choice}}"/>
				{% endfor %}
			</td></tr>
			</table>
			</fieldset>
			<p></p>
			<center><input type="submit" name="acceptBatchEntry" value="{{button_add_stories}}" class="button"></center>
		{% endfor %}
		
		{% else %}
			{{blurbs|dictLookup:"cannot_enter_batch"}}
		{% endif %}

		</form>	
		</div>
	</div>
	{% include "../common_footer.html" %}
	</body>
</html>
